import java.util.HashMap;
import java.util.Stack;


public class Fonction extends Ident {

	private HashMap<String, Ident> idents;
	private Stack<String> param;
	
	public Fonction(int type) {
		super(type);
	}
	
	public Fonction(int type, HashMap<String, Ident> idents) {
		super(type);
		this.idents = idents;
	}

	public int getNature() {
		return Ident.FONCTION;
	}
	
	public int getNbParametres() {
		return param.size();
	}
	
	public int getNbVariables() {
		int nb = 0;
		
		if (idents == null)
			return 0;
		
		for (Ident ident : idents.values())
			if (ident.getNature() != PARAMETRE_FONCTION)
				nb++;
		
		return nb;
	}
	
	public HashMap<String, Ident> getIdents() {
		return idents;
	}

	public void setIdents(HashMap<String, Ident> idents) {
		this.idents = idents;
	}

	public void setParam(Stack<String> stack) {
		param = (Stack<String>) stack.clone();
	}

	public int getParamType(int nb) {
		return idents.get(param.get(nb)).getType();
	}

}

